﻿@using WXY.Course.Model;
@model IList<RecommendInfo>
@{
    ViewBag.Title = "List";
}
<style type="text/css">
    .panel_info p { padding: 5px; }
    .c_msg { color: red; }
</style>
<div class="m_rtop">
    <h3>
        <label>
            推荐管理
        </label>
        <span>></span>推荐列表
    </h3>
</div>
<p class="m_ptop">
    <input type="button" id="btnAdd" class="btn_bg1" value="新增推荐">
</p>
<table width="980" cellpadding="0" cellspacing="0" border="1"
       class="tab1">
    <tr>
        <th width="150">操作</th>
        <th width="160">名称</th>
        <th width="100">位置</th>
        <th width="210">图片</th>
        <th width="210">链接</th>
    </tr>
    @if (Model != null)
    {
        var list = Enum.GetValues(typeof(RecommendPosition));
        for (int i = 0; i < list.Length; i++)
        {
            foreach (var item in Model.Where(m => (int)m.Position == (int)list.GetValue(i)))
            {
                <tr>
                    <td align="center">
                        <input type="hidden" value="@item.Code">
                        <a href="javascript:void(0)" name="deleteLink">删除</a>
                    </td>
                    <td>@item.Name</td>
                    <td>@Html.DisplayName(typeof(RecommendPosition), item.Position.ToString(), AttributeTargets.Field)</td>
                    <td style="text-align:center">
                        <img width="200" height="80" src="@item.Image">
                    </td>
                    <td>@item.Url</td>
                </tr>
            }
            if (i != list.Length - 1)
            {
                <tr>
                    <td colspan="4"></td>
                </tr>
            }
        }
    }
</table>

<div id="addPanel" class="panel_info" style="display: none">
    <p class="c_msg"></p>
    <p>
        <label>
            名&nbsp;&nbsp;&nbsp;&nbsp;称：
        </label>
        <input type="text" id="name" />
    </p>
    <p>
        <label>
            位&nbsp;&nbsp;&nbsp;&nbsp;置：
        </label>
        @Html.EnumDropDownList("position", typeof(RecommendPosition), "请选择推荐位置", new { id = "position" })
    </p>
    <p>
        <label>
            链&nbsp;&nbsp;&nbsp;&nbsp;接：
        </label>
        <input type="text" id="url" />
        <span class="tip">可空</span>
    </p>

    <p>
        <label>
            图片地址：
        </label>
        <input id="imageKey" type="text" />
    </p>
    <p class="m_p160">
        <img id="image" width="231" height="151">
    </p>
</div>
<script src="~/Scripts/recommend.js"></script>